function [O sim_mom] = imo_2011_NLSFE(beta,data,prm,output)

% Fixed parameters
p = prm.p;
K = data.K;             % Number of destination         
K2 = data.K2(p);        % Number of destinations for product p

% Vector to be estimated
t = exp(beta(1:K2));
a = beta(K2+1:end-1);
phisig1 = beta(end);

% Find the correct indices for t
i = 1; 
for n=1:data.K
    if (data.usedata(n,p)==1) 
        t_arr(n) = t(i); 
        a_arr(n) = a(i); 
        i = i+1;
    end
end

eta = [];
for n=1:data.K
    if data.usedata(n,p)==1
      lnXhat = a_arr(n) + phisig1*log(data.price{n,p} + t_arr(n));         
      resid = data.lnX{n,p} - lnXhat;
      eta = [eta; resid];
    end
end
O = sum(eta.^2);
end